home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-03-04 | 27.9 KB | 967 lines | [TEXT/PJMM] |
- program FCLogScan;
-
- uses
- Globals, TextUtils, Configure;
-
- const
- SINGLEQUOTE = chr(39);
- ENDLINE = chr(13);
- kRecLimit = 20;
- kSessLimit = 100;
-
- type
- BaudSpeed = record
- Baud300, Baud1200, Baud2400, Baud4800, Baud9600, Baud14400, Baud19200, Baud38400: integer;
- end;
- NewU = array[1..1] of string[25];
- NewUPtr = ^NewU;
- NewUHdl = ^NewUPtr;
- NameStuff = record
- Name: string[35];
- NameCount: integer;
- startTime, totalTime: longint;
- specialLine: boolean;
- end;
- callerIDs = array[1..1] of NameStuff;
- callerPtr = ^callerIDs;
- callerHdl = ^callerPtr;
- hourArray = record
- sessNum: integer;
- thirdHours: array[0..71] of char;
- sessBegin, sessTotalTime: longint;
- isActive: boolean;
- end;
- timeUsed = array[1..1] of hourArray;
- timePtr = ^timeUsed;
- timeHdl = ^timePtr;
-
- var
- myCallerHdl: callerHdl;
- myTimeHdl: timeHdl;
- NewUsers: NewUHdl;
- BaudRates: BaudSpeed;
- KnownSession: array[0..kSessLimit] of boolean;
- session: array[1..kRecLimit] of integer;
- CLineCount, GUICount, HowManyCallers, HowManySessions: integer;
- StartHour, EndHour, newUserCount, BaudCount: integer;
- currentLog, gSessString: str255;
- usingAMPM, DoBaudReport: boolean;
- logStartTime, logEndTime: longint;
- runDialog: DialogPtr;
- oldPort: GrafPtr;
-
- {----------------------------------------------------------------- }
-
- function MakeMonthString (monthNum: integer): str255;
-
- begin
- case monthNum of
- 1:
- MakeMonthString := 'Jan';
- 2:
- MakeMonthString := 'Feb';
- 3:
- MakeMonthString := 'Mar';
- 4:
- MakeMonthString := 'Apr';
- 5:
- MakeMonthString := 'May';
- 6:
- MakeMonthString := 'Jun';
- 7:
- MakeMonthString := 'Jul';
- 8:
- MakeMonthString := 'Aug';
- 9:
- MakeMonthString := 'Sep';
- 10:
- MakeMonthString := 'Oct';
- 11:
- MakeMonthString := 'Nov';
- 12:
- MakeMonthString := 'Dec';
- otherwise
- ;
- end;
- end;
-
- {----------------------------------------------------------------- }
-
- procedure AddNewSession (sessNum: integer; currTime: longint);
-
- var
- newSize: longint;
- counter: integer;
- sessRec: hourArray;
-
- begin
- KnownSession[sessNum] := true;
- HowManySessions := succ(HowManySessions);
- newSize := GetHandleSize(Handle(myTimeHdl)) + sizeOf(hourArray);
- SetHandleSize(Handle(myTimeHdl), newSize);
- if MemError <> NoErr then
- begin
- SysBeep(6);
- ExitToShell
- end;
- sessRec.sessNum := sessNum;
- for counter := 0 to 71 do
- sessRec.thirdHours[counter] := NoCallSymbol;
- sessRec.sessBegin := currTime;
- sessRec.sessTotalTime := 0;
- sessRec.isActive := true;
- myTimeHdl^^[HowManySessions] := sessRec
- end;
-
- {----------------------------------------------------------------- }
-
- function getTime (logString: str255): longint;
-
- { Returns number of seconds of time from log line }
- { [9/24/91 8:15:18 AM] Session 1.571 Start Sess 0 User 'Paul W Hampton' }
-
- var
- dateString, timeString, tempString, yearString, monthString, dayString, hourString, minuteString, secString: str255;
- myDTR: DateTimeRec;
- nowSecs: longint;
-
- begin
- tempString := copy(logString, 2, pos(']', logString) - 2); {get date & time without brackets}
- dateString := copy(tempString, 1, pos(' ', tempString) - 1); {just want the date}
- timeString := copy(tempString, pos(' ', tempString) + 1, 255); {just want the time}
- monthString := copy(dateString, 1, pos('/', dateString) - 1);
- dateString := copy(dateString, pos('/', dateString) + 1, 255);
- dayString := copy(dateString, 1, pos('/', dateString) - 1);
- yearString := copy(dateString, pos('/', dateString) + 1, 255);
- hourString := copy(timeString, 1, pos(':', timeString) - 1);
- timeString := copy(timeString, pos(':', timeString) + 1, 255);
- minuteString := copy(timeString, 1, pos(':', timeString) - 1);
- timeString := copy(timeString, pos(':', timeString) + 1, 255);
- secString := copy(timeString, 1, pos(' ', timeString) - 1);
-
- with myDTR do
- begin
- year := 1900 + GetValue(yearString);
- month := GetValue(monthString);
- day := GetValue(dayString);
- hour := GetValue(hourString);
- if (pos('PM', timeString) > 0) & (hour < 12) then
- hour := hour + 12;
- if (pos('AM', timeString) > 0) & (hour = 12) then
- hour := 0;
- minute := GetValue(minuteString);
- second := GetValue(secString);
- end;
- Date2Secs(myDTR, nowSecs);
- getTime := nowSecs
- end;
-
- {----------------------------------------------------------------- }
-
- procedure getStartTime (logString: str255);
-
- var
- dateString, hourString: str255;
-
- begin
- logStartTime := GetTime(logString);
- dateString := copy(logString, 2, pos(']', logString) - 2); {get date & time without brackets}
- dateString := copy(dateString, pos(' ', dateString) + 1, 255); {just want the time}
- if (pos('AM', dateString) = 0) & (pos('PM', dateString) = 0) then
- usingAMPM := false
- else
- usingAMPM := true;
- hourString := copy(dateString, 1, pos(':', dateString) - 1);
- if usingAMPM & (hourString = '12') & (pos('PM', dateString) = 0) then
- hourString := '0';
- StartHour := getValue(hourString)
- end;
-
- {----------------------------------------------------------------- }
-
- function GetGraphPos (dateTimeString: str255): integer;
-
- { dateTimeString is of form 9/17/91 2:17:56 PM }
-
- var
- bonus: integer;
- hourString, minuteString, tempString: str255;
- totalMinutes, totalThirds: integer;
-
- begin
- tempString := copy(dateTimeString, pos(' ', dateTimeString) + 1, 255); {just want the time}
- hourString := copy(tempString, 1, pos(':', tempString) - 1);
- if usingAMPM & (pos('PM', tempString) > 0) & (GetValue(hourString) <> 12) then {string is now 2:17:56 PM}
- bonus := 12 * 60
- else
- bonus := 0;
- if usingAMPM & (pos('AM', tempString) <> 0) & (hourString = '12') then
- hourString := '0';
- EndHour := getValue(hourString);
- tempString := copy(tempString, pos(':', tempString) + 1, 255);
- minuteString := copy(tempString, 1, pos(':', tempString) - 1);
- totalMinutes := (60 * getValue(hourString)) + getValue(minuteString) + bonus;
- totalThirds := totalMinutes div 20;
-
- if totalThirds > 71 then
- totalThirds := 71;
- GetGraphPos := totalThirds
- end;
-
- {----------------------------------------------------------------- }
-
- function GetSessNum (lineString: str255): integer;
-
- var
- mark: integer;
- sessNum, currTime: longint;
-
- begin
- currTime := GetTime(lineString);
- mark := pos('Sess ', lineString);
- mark := mark + 5; {length of 'Sess '}
- lineString := copy(lineString, mark, 255);
- mark := 1;
- while (lineString[mark] in ['0'..'9']) & (mark < length(lineString)) do
- mark := succ(mark);
- lineString := copy(lineString, 1, pred(mark));
- StringToNum(lineString, sessNum);
- if (HowManySessions = 0) | (not KnownSession[sessNum]) then
- AddNewSession(sessNum, currTime);
- GetSessNum := sessNum
- end;
-
- {----------------------------------------------------------------- }
-
- procedure GetSessionFromLine (lineString: str255);
-
- { [9/24/91 8:15:18 AM] Session 1.571 Start Sess 0 User 'Paul W Hampton' }
- { - or - }
- { [9/17/91 2:17:56 PM] Command Line Session Start C-Sess 0 User 'DTOPS' }
-
- var
- count: integer;
- sessNum, currentLogTime: longint;
- dateTimeString, tempString: str255;
- sessExists, sessStart: boolean;
-
- begin
- sessNum := GetSessNum(lineString);
- currentLogTime := GetTime(lineString);
- if (pos(gSessStart, lineString) > 0) then
- sessStart := true
- else
- sessStart := false;
- dateTimeString := copy(lineString, 2, pos(']', lineString) - 2); {get date & time without brackets}
- for count := 1 to HowManySessions do
- if myTimeHdl^^[count].sessNum = sessNum then
- begin
- if sessStart then
- myTimeHdl^^[count].sessBegin := currentLogTime;
- myTimeHdl^^[count].thirdHours[GetGraphPos(dateTimeString)] := CallSymbol;
- myTimeHdl^^[count].isActive := true;
- leave
- end;
- end;
-
- {----------------------------------------------------------------- }
-
- procedure GetBaudFromLine (logLine: str255);
-
- { [10/11/91 10:11:13 PM] Session 1.600 Start @2400 baud Sess 0 User 'WParker' }
-
- var
- baudString: str255;
- OKBaud: boolean;
-
- begin
- if (pos('@', logLine) > 0) then
- begin
- OKBaud := true;
- BaudCount := succ(BaudCount);
- baudString := copy(logLine, (succ(pos('@', logLine))), 255);
- baudString := copy(baudString, 1, (pred(pos(' ', baudString))));
- if (length(baudString) > 5) | (length(baudString) < 3) then
- baudString := '';
- case GetValue(baudString) of
- 300:
- BaudRates.Baud300 := succ(BaudRates.Baud300);
- 1200:
- BaudRates.Baud1200 := succ(BaudRates.Baud1200);
- 2400:
- BaudRates.Baud2400 := succ(BaudRates.Baud2400);
- 4800:
- BaudRates.Baud4800 := succ(BaudRates.Baud4800);
- 9600:
- BaudRates.Baud9600 := succ(BaudRates.Baud9600);
- 14400:
- BaudRates.Baud14400 := succ(BaudRates.Baud14400);
- 19200:
- BaudRates.Baud19200 := succ(BaudRates.Baud19200);
- 38400:
- BaudRates.Baud38400 := succ(BaudRates.Baud38400);
- otherwise
- begin
- OKBaud := false;
- BaudCount := pred(BaudCount);
- end;
- end { case }
- end; { if (pos('@', logLine) > 0) }
- if OKBaud then
- DoBaudReport := true;
- end;
-
- {----------------------------------------------------------------- }
-
- procedure GetNameFromLine (logString: str255; beginSess: boolean);
-
- { caller name is last string on the line, contained within 'single quotes' i.e. }
- { [9/24/91 8:15:18 AM] Session 1.571 Start Sess 0 User 'Paul W Hampton' }
- { - or - }
- { [9/17/91 2:17:56 PM] Command Line Session Start C-Sess 0 User 'DTOPS' }
-
- var
- count: integer;
- newSize, currTime: longint;
- alreadyExists: boolean;
- nameString: str255;
- currName: NameStuff;
- SpecialCaller: boolean;
-
- begin
- SpecialCaller := false;
- if beginSess then
- if (pos(gSessString, logString) > 0) then
- SpecialCaller := true;
- nameString := copy(logString, 1, length(logString) - 1); {trim last single quote}
- while pos(SINGLEQUOTE, nameString) > 0 do
- nameString := copy(nameString, succ(pos(SINGLEQUOTE, nameString)), 255);
- alreadyExists := false;
- currTime := GetTime(logString);
- for count := 1 to HowManyCallers do
- begin
- currName := myCallerHdl^^[count];
- if currName.Name = nameString then
- begin
- currName.NameCount := succ(currName.NameCount);
- if beginSess then
- begin
- currName.startTime := currTime;
- currName.specialLine := SpecialCaller;
- end
- else
- begin {end of session}
- if currName.startTime <> 0 then
- currName.totalTime := currTime - currName.startTime + currName.totalTime
- else
- currName.totalTime := currTime - logStartTime + currName.totalTime;
- currName.startTime := 0;
- end;
- alreadyExists := true;
- myCallerHdl^^[count] := currName;
- leave
- end;
- end;
- if not alreadyExists then
- begin
- HowManyCallers := succ(HowManyCallers);
- newSize := sizeOf(callerIDs) + (HowManyCallers * sizeOf(NameStuff));
- SetHandleSize(Handle(myCallerHdl), newSize);
- MoveHHi(Handle(myCallerHdl));
- HLock(Handle(myCallerHdl));
- currName.Name := nameString;
- currName.NameCount := 1;
- currName.startTime := currTime;
- currName.totalTime := 0;
- currName.specialLine := SpecialCaller;
- myCallerHdl^^[HowManyCallers] := currName;
- HUnlock(Handle(myCallerHdl))
- end
- end;
-
- {----------------------------------------------------------------- }
-
- procedure addNewUser (logLine: str255);
-
-
- { line reads [10/1/91 9:41:39 AM] User Ronald a Luna auto-registered Sess 0 }
- { gAutoRegister = ' auto-registered Sess ' }
- var
- NewSize: longint;
- tempString: str255;
-
- begin
- newUserCount := succ(newUserCount);
- SetHandleSize(Handle(NewUsers), sizeOf(NewU) + (pred(newUserCount) * 26)); {26 = size of string[25]}
- tempString := copy(logLine, (pos('User', logLine) + 5), 255); {clip off User }
- tempString := copy(tempString, 1, pred(pos(gAutoRegister, tempString)));
- if length(tempString) > 25 then
- tempString := copy(tempString, 1, 25);
- NewUsers^^[newUserCount] := tempString;
- end;
-
- {----------------------------------------------------------------- }
-
- procedure EndSession (lineString: str255);
-
- var
- dateTimeString: str255;
- ClosePos, sessNum, graphPos, counter: integer;
- currentLogTime: longint;
- timeRecord: hourArray;
-
- begin
- dateTimeString := copy(lineString, 2, pos(']', lineString) - 2); {get date & time without brackets}
- ClosePos := GetGraphPos(dateTimeString); {get session end time}
- sessNum := GetSessNum(lineString);
- graphPos := GetGraphPos(dateTimeString);
- for counter := 1 to HowManySessions do
- begin
- timeRecord := myTimeHdl^^[counter];
- if (timeRecord.sessNum = sessNum) & timeRecord.isActive then
- begin
- GetNameFromLine(lineString, false); {false means end session}
- timeRecord.isActive := false;
- currentLogTime := GetTime(lineString);
- timeRecord.sessTotalTime := timeRecord.sessTotalTime + (currentLogTime - timeRecord.sessBegin);
- timeRecord.sessBegin := 0;
- while (timeRecord.thirdHours[graphPos] <> CallSymbol) & (graphPos >= (StartHour * 3)) do
- begin
- timeRecord.thirdHours[graphPos] := CallSymbol;
- graphPos := pred(graphPos)
- end;
- myTimeHdl^^[counter] := timeRecord;
- leave
- end { if timeRecord.sessNum = sessNum }
- end;
- end;
-
- {----------------------------------------------------------------- }
-
- procedure Analyze (logLine: str255);
-
- begin
- if pos('[', logLine) = 1 then
- begin
- if StartHour < 0 then
- getStartTIme(logLine);
- logEndTime := GetTime(logLine);
- if (pos(gAutoRegister, logLine) > 0) then
- addNewUser(logLine);
- if (pos(gSessStart, logLine) > 0) then
- begin
- GetBaudFromLine(logLine);
- GetNameFromLine(logLine, true); {true means begin session}
- GetSessionFromLine(logLine);
- if pos(gCommandLine, logLine) > 0 then
- CLineCount := succ(CLineCount)
- else
- GUICount := succ(GUICount)
- end
- else if (pos(gSessionEnd, logLine) > 0) then
- EndSession(logLine)
- end
- end;
-
- {----------------------------------------------------------------- }
-
- procedure Initialize;
-
- var
- counter: integer;
-
- begin
- StartHour := -1;
- DoBaudReport := false;
- myCallerHdl := callerHdl(newHandle(sizeOf(callerIDs)));
- myTimeHdl := timeHdl(newHandle(0));
- NewUsers := newUHdl(newHandle(sizeOf(NewU)));
- BaudRates.Baud300 := 0;
- BaudRates.Baud1200 := 0;
- BaudRates.Baud2400 := 0;
- BaudRates.Baud4800 := 0;
- BaudRates.Baud9600 := 0;
- BaudRates.Baud14400 := 0;
- BaudRates.Baud19200 := 0;
- BaudRates.Baud38400 := 0;
- BaudCount := 0;
- newUserCount := 0;
- HowManySessions := 0;
- HowManyCallers := 0;
- CLineCount := 0;
- GUICount := 0;
- for counter := 1 to kRecLimit do
- session[counter] := 0;
- for counter := 0 to kSessLimit do
- KnownSession[counter] := false
- end;
-
- {----------------------------------------------------------------- }
-
- procedure CleanUp;
-
- begin
- DisposHandle(Handle(myCallerHdl));
- DisposHandle(Handle(myTimeHdl));
- DisposHandle(Handle(NewUsers));
- end;
-
- {----------------------------------------------------------------- }
-
- procedure sortTimeHandle (Start, Finish: integer);
-
- var
- tempHourArray: hourArray;
- Left, Right, StarterValue: integer;
-
- begin
- Left := Start;
- Right := Finish;
- StarterValue := myTimeHdl^^[(Start + Finish) div 2].sessNum; { Pick a starter }
- repeat
- while myTimeHdl^^[Left].sessNum < StarterValue do
- Left := Left + 1; { Find a bigger value on the left }
- while StarterValue < myTimeHdl^^[Right].sessNum do
- Right := Right - 1; { Find a smaller value on the right }
- if Left <= Right then
- begin {If we haven't gone too far... }
- tempHourArray := myTimeHdl^^[Left];
- myTimeHdl^^[Left] := myTimeHdl^^[Right];
- myTimeHdl^^[Right] := tempHourArray;
- Left := Left + 1;
- Right := Right - 1
- end; { then }
- until Right <= Left;
- if Start < Right then
- sortTimeHandle(Start, Right);
- if Left < Finish then
- sortTimeHandle(Left, Finish);
- end;
-
- {----------------------------------------------------------------- }
-
- function MakeHMS (secTotal: longint): str255;
-
- var
- hours, minutes, seconds: integer;
- minuteString, secondsString: str255;
-
- begin
- hours := secTotal div 3600;
- secTotal := secTotal mod 3600;
- minutes := secTotal div 60;
- minuteString := StringOf(minutes : 1);
- if length(minuteString) = 1 then
- minuteString := concat('0', minuteString);
- seconds := secTotal mod 60;
- secondsString := StringOf(seconds : 1);
- if length(secondsString) = 1 then
- secondsString := concat('0', secondsString);
- MakeHMS := concat(RPadString(StringOf(hours : 1), 2), ':', minuteString, ':', secondsString)
- end;
-
- {----------------------------------------------------------------- }
-
- function MakeDateline (Secs: longint): str255;
-
- var
- DTR: DateTimeRec;
- tempString, timeString, AMPM, myDayOfWeek: str255;
-
- begin
- Secs2Date(Secs, DTR);
- if DTR.minute < 10 then
- tempString := concat('0', stringOf(DTR.minute : 1))
- else
- tempString := stringOf(DTR.minute : 1);
- if usingAMPM then
- begin
- AMPM := 'AM';
- if DTR.hour > 12 then
- begin
- DTR.hour := DTR.hour - 12;
- AMPM := 'PM';
- end
- else if DTR.hour = 12 then
- AMPM := 'PM';
- timeString := concat(stringOf(DTR.hour : 1), ':', tempString, ' ', AMPM);
- end
- else
- timeString := concat(stringOf(DTR.hour : 1), ':', stringOf(DTR.minute : 1));
- case DTR.dayOfWeek of
- 1:
- myDayOfWeek := 'Sunday';
- 2:
- myDayOfWeek := 'Monday';
- 3:
- myDayOfWeek := 'Tuesday';
- 4:
- myDayOfWeek := 'Wednesday';
- 5:
- myDayOfWeek := 'Thursday';
- 6:
- myDayOfWeek := 'Friday';
- 7:
- myDayOfWeek := 'Saturday';
- otherwise
- myDayOfWeek := '';
- end;
- tempString := concat(timeString, ' ', myDayOfWeek, ' ', stringOf(DTR.month : 1), '/', stringOf(DTR.day : 1), '/', stringOf(DTR.year mod 100 : 1));
- MakeDateline := tempString
- end;
-
- {----------------------------------------------------------------- }
-
- function PrintUse (totalSecs: longint; mult: integer): str255;
-
- { Forms line with total time and percentage of use. Called with multiplier for how many 24-hour days }
-
- const
- kSecsInDay = longint(24 * 6 * 6); {since we're going to multiply by 100 to get percentage, do it here by division }
-
- begin
- if mult > 0 then
- PrintUse := concat(' ', TimeUsedTitle, ' ', MakeHMS(totalSecs), ' --', RPadString(stringOf(totalSecs div (mult * kSecsInDay) : 1), 3), '%')
- end;
-
- {----------------------------------------------------------------- }
-
- function MakeBaudLine (BaudString: str255; BaudRate: integer): str255;
-
- var
- baudReal: real;
- baudInt: integer;
- tempString: str255;
-
- begin
- tempString := concat(LPadString(BaudString, 6), '--', RPadString(stringOf(BaudRate : 1), 4));
- baudReal := 100 * (BaudRate / BaudCount);
- baudInt := trunc(baudReal + 0.5);
- MakeBaudLine := concat(tempString, RPadString(concat(stringOf(baudInt : 1), '%'), 6))
- end;
-
- {----------------------------------------------------------------- }
-
- procedure WriteReport (reportRef: integer; doBriefFile: boolean);
-
- var
- count, i, OKSessCount, sequenceCount, howManyDays: integer;
- Err: OSErr;
- OKSession: boolean;
- curName: NameStuff;
- sessRec: hourArray;
- sessCumeTime: longint;
- briefRef: integer;
- hourString, specialSession, sessMark: str255;
-
- {---------------------------------}
-
- function Wr2 (ref1, ref2: integer; theString: str255): OSErr;
-
- var
- theErr: OSErr;
-
- begin
- theErr := Wr(ref1, theString);
- if doBriefFile & (theErr = NoErr) then
- theErr := Wr(ref2, theString);
- Wr2 := theErr
- end;
-
- {---------------------------------}
-
- function WrLn2 (ref1, ref2: integer; theString: str255): OSErr;
-
- var
- theErr: OSErr;
-
- begin
- theErr := WrLn(ref1, theString);
- if doBriefFile & (theErr = NoErr) then
- theErr := WrLn(ref2, theString);
- WrLn2 := theErr
- end;
-
- {---------------------------------}
-
- begin
- sessCumeTime := 0;
- howManyDays := 0;
-
- if doBriefFile & (Defaults.BriefPath <> '') & (Defaults.BriefName <> '') then
- begin
- err := FSDelete(concat(Defaults.BriefPath, Defaults.BriefName), vRefNum);
- err := Create(concat(Defaults.BriefPath, Defaults.BriefName), vRefNum, Defaults.Creator, 'TEXT');
- err := FSOpen(concat(Defaults.BriefPath, Defaults.BriefName), vRefNum, briefRef);
- if err <> NoErr then
- doBriefFile := false
- end
- else
- doBriefFile := false;
-
- if TitleString[length(TitleString)] <> ENDLINE then
- TitleString := concat(TitleString, ENDLINE);
- TitleString := ReplaceInString(TitleString, '^0', MakeDateline(logStartTime));
- TitleString := ReplaceInString(TitleString, '^1', MakeDateline(logEndTime));
- Err := Wr2(reportRef, briefRef, TitleString);
-
- if SummaryString[length(SummaryString)] <> ENDLINE then
- SummaryString := concat(SummaryString, ENDLINE);
- SummaryString := ReplaceInString(SummaryString, '^0', stringOf(GUICount : 1));
- SummaryString := ReplaceInString(SummaryString, '^1', stringOf(CLineCount : 1));
- SummaryString := ReplaceInString(SummaryString, '^2', stringOf(GUICount + CLineCount : 1));
- Err := WrLn2(reportRef, briefRef, SummaryString);
-
- if LegendString[length(LegendString)] <> ENDLINE then
- LegendString := concat(LegendString, ENDLINE);
- Err := WrLn2(reportRef, briefRef, LegendString);
-
- hourString := '';
- for count := StartHour to 23 do
- if count < 10 then
- hourString := concat(hourString, stringOf(count : 1), ' ')
- else
- hourString := concat(hourString, stringOf(count : 1), ' ');
- for count := 0 to pred(StartHour) do
- if count < 10 then
- hourString := concat(hourString, stringOf(count : 1), ' ')
- else
- hourString := concat(hourString, stringOf(count : 1), ' ');
- Err := WrLn2(reportRef, briefRef, hourString);
-
- MoveHHi(Handle(myTimeHdl));
- HLock(Handle(myTimeHdl));
- sortTimeHandle(1, HowManySessions);
- for count := 1 to HowManySessions do
- begin
- OKSession := true;
- sessRec := myTimeHdl^^[count];
- for OKSessCount := 1 to HowManyOmits do
- if sessRec.sessNum = Defaults.IgnoreSess[OKSessCount] then
- begin
- OKSession := false;
- leave
- end;
- if OKSession then
- begin
- for i := (StartHour * 3) to 71 do
- Err := Wr2(reportRef, briefRef, sessRec.thirdHours[i]);
- for i := 0 to pred((StartHour) * 3) do
- Err := Wr2(reportRef, briefRef, sessRec.thirdHours[i]);
- Err := WrLn2(reportRef, briefRef, '');
- end
- end;
- for count := 1 to HowManySessions do
- begin
- OKSession := true;
- sessRec := myTimeHdl^^[count];
- for OKSessCount := 1 to HowManyOmits do
- if sessRec.sessNum = Defaults.IgnoreSess[OKSessCount] then
- begin
- OKSession := false;
- leave
- end;
- if OKSession then
- begin
- Err := WrLn2(reportRef, briefRef, concat(LineTitle, ' ', StringOf(count : 1), PrintUse(sessRec.sessTotalTime, 1)));
- sessCumeTime := sessCumeTime + sessRec.sessTotalTime;
- howManyDays := succ(howManyDays);
- end;
- end; {for count := 1 to HowManySessions}
- Err := WrLn2(reportRef, briefRef, concat(TotalTitle, ' ', PrintUse(sessCumeTime, howManyDays), ENDLINE));
-
- if DoBaudReport then
- begin
- Err := WrLn2(reportRef, briefRef, ConnectionSpeedsTitle);
- if (BaudRates.Baud300 > 0) then
- Err := WrLn2(reportRef, briefRef, MakeBaudLine('300', BaudRates.Baud300));
- if (BaudRates.Baud1200 > 0) then
- Err := WrLn2(reportRef, briefRef, MakeBaudLine('1200', BaudRates.Baud1200));
- if (BaudRates.Baud2400 > 0) then
- Err := WrLn2(reportRef, briefRef, MakeBaudLine('2400', BaudRates.Baud2400));
- if (BaudRates.Baud4800 > 0) then
- Err := WrLn2(reportRef, briefRef, MakeBaudLine('4800', BaudRates.Baud4800));
- if (BaudRates.Baud9600 > 0) then
- Err := WrLn2(reportRef, briefRef, MakeBaudLine('9600', BaudRates.Baud9600));
- if (BaudRates.Baud14400 > 0) then
- Err := WrLn2(reportRef, briefRef, MakeBaudLine('14400', BaudRates.Baud14400));
- if (BaudRates.Baud19200 > 0) then
- Err := WrLn2(reportRef, briefRef, MakeBaudLine('19200', BaudRates.Baud19200));
- if (BaudRates.Baud38400 > 0) then
- Err := WrLn2(reportRef, briefRef, MakeBaudLine('38400', BaudRates.Baud38400));
- Err := WrLn(reportRef, '');
- end; {if DoBaudReport }
- if doBriefFile then
- err := FSClose(briefRef);
-
- specialSession := concat('[', StringOf(Defaults.SpecialSess : 0), ']');
-
- if newUserCount > 0 then
- begin
- Err := WrLn(reportRef, RegistrationsTitle);
- HLock(Handle(NewUsers));
- for count := 1 to newUserCount do
- Err := WrLn(reportRef, NewUsers^^[count]);
- HUnlock(Handle(NewUsers));
- Err := WrLn(reportRef, '');
- end;
- Err := WrLn(reportRef, NameCallsTimeTitle);
- for count := 1 to HowManyCallers do
- begin
- curName := myCallerHdl^^[count];
- if curName.specialLine then
- sessMark := specialSession
- else
- sessMark := ' ';
- Err := WrLn(reportRef, concat(LPadString(curName.Name, 24), RPadString(stringOf(curName.NameCount : 1), 6), RPadString(stringOf((curName.totalTime + 30) div 60 : 1), 6), RPadString(sessMark, 6)))
- end;
- HUnlock(Handle(myTimeHdl))
- end;
-
- {----------------------------------------------------------------- }
-
- procedure ProcessFile (fileName: str255; readRef, vRef: integer; doBriefFile: boolean);
-
- var
- err: OSErr;
- logLine: str255;
- reportRef: integer;
-
- begin
- Initialize;
- Err := FSDelete(fileName, vRef);
- Err := Create(fileName, vRef, Defaults.Creator, 'TEXT');
- if Err = NoErr then
- begin
- Err := FSOpen(fileName, vRef, reportRef);
- while not AtEOF(readRef) do
- begin
- Err := ReadALine(readRef, logLine);
- Analyze(logLine);
- end;
- WriteReport(reportRef, Defaults.DoBriefRept);
- Err := FSClose(reportRef);
- end;
- CleanUp
- end;
-
- {----------------------------------------------------------------- }
-
- procedure ShowRunDialog;
-
- begin
- SetCursor(GetCursor(watchCursor)^^);
- GetPort(oldPort);
- runDialog := GetNewDialog(501, nil, POINTER(-1));
- SetPort(runDialog);
- DrawDialog(runDialog);
- end;
-
- {----------------------------------------------------------------- }
-
- procedure KillRunDialog;
-
- begin
- DisposDialog(runDialog);
- SetPort(oldPort);
- InitCursor;
- end;
-
- {----------------------------------------------------------------- }
-
- procedure ScanFiles;
-
- var
- where: point;
- reply: SFReply;
- typeList: SFTypeList;
- readRef, reportRef: integer;
- Err: OSErr;
- logLine: str255;
- keepLooping: boolean;
- dirID: longint;
-
- begin
- keepLooping := true;
- where.v := 20;
- where.h := 20;
- typeList[0] := 'TEXT';
- while keepLooping = true do
- begin
- SFGetFile(where, '', nil, 1, typeList, nil, reply);
- if reply.good then
- begin
- currentLog := reply.fName;
- Err := FSOpen(currentLog, reply.vRefNum, readRef);
- if (Err = NoErr) then
- begin
- SFPutFile(where, 'Please name report', concat(currentLog, ' report'), nil, reply);
- if reply.good then
- begin
- ShowRunDialog;
- ProcessFile(reply.fName, readRef, reply.vRefNum, false);
- KillRunDialog
- end;
- end;
- Err := FSClose(readRef);
- end
- else
- keepLooping := false
- end
- end;
-
- {----------------------------------------------------------------- }
-
- procedure AutoReport;
-
- const
- daySecs = 86400;
-
- var
- Err: OSErr;
- fName: str255;
- dirID, secs: longint;
- readRef: integer;
- DTR: DateTimeRec;
-
- begin
- Initialize;
- GetDateTime(secs);
- secs := secs - daySecs;
- Secs2Date(secs, DTR);
- fName := concat(MakeMonthString(DTR.month), stringOf(DTR.day : 1), '/', stringOf(DTR.year : 1));
- Err := HOpen(vRefNum, dirID, concat(Defaults.FCLogPath, fName), fsRdPerm, readRef);
- if (Err = NoErr) then
- ProcessFile(concat(Defaults.FCLogPath, fName, ' report'), readRef, vRefNum, true);
- Err := FSClose(readRef);
- CleanUp
- end;
-
- {----------------------------------------------------------------- }
-
- var
- err: OSErr;
- dirID: longint;
- tempSettings: Settings;
-
- begin
- MaxApplZone;
- InitCursor;
- err := HGetVol(nil, vRefNum, dirID);
- ReadDefaults;
- gSessString := concat('Sess ', stringOf(Defaults.SpecialSess : 0));
- if Button then
- begin
- tempSettings := Defaults;
- if Configure(tempSettings) then
- WriteResources(tempSettings)
- end
- else if Defaults.Automatic then
- begin
- ShowRunDialog;
- AutoReport;
- KillRunDialog;
- end
- else
- ScanFiles
- end.